<template>
  <el-card class="app-container">
    <c-u-r-d-table :option="option" ref="table"/>
    <dialog-columns-form
      v-model="formData"
      width="400px"
      title="修改销量"
      :visible.sync="totalSaleNumShowed"
      :columns="totalSaleNumColumns"
      @submit="handleSubmitTotalSaleNum"
    />
    <dialog-columns-form
      v-model="formData"
      width="400px"
      title="日常活动"
      :visible.sync="dailyActShowed"
      :columns="dailyActColumns"
      @submit="handleSubmitDailyAct"
    />
    <dialog-columns-form
      v-model="formData"
      width="400px"
      title="小黑盒"
      :visible.sync="blackBoxShowed"
      :columns="blackBoxColumns"
      @submit="handleSubmitBlackBox"
    />
    <dialog-columns-form
      v-model="formData"
      width="400px"
      title="导购素材"
      :visible.sync="guideMaterialShowed"
      :columns="guideMaterialColumns"
      @submit="handleSubmitGuideMaterial"
    />
    <dialog-columns-form
      v-model="formData"
      width="400px"
      title="银河"
      :visible.sync="milkyWayShowed"
      :columns="milkyWayColumns"
      @submit="handleSubmitMilkyWay"
    />
    <dialog-columns-form
      v-model="formData"
      width="400px"
      title="微详情"
      :visible.sync="microDetailShowed"
      :columns="microDetailColumns"
      @submit="handleSubmitMicroDetail"
    />
    <dialog-columns-form
      v-model="formData"
      width="400px"
      title="搭配购"
      :visible.sync="combinationPurchaseShowed"
      :columns="combinationPurchaseColumns"
      @submit="handleSubmitCombinationPurchase"
    />
    <dialog-columns-form
      v-model="formData"
      width="400px"
      title="搜索视频"
      :visible.sync="searchVideoShowed"
      :columns="searchVideoColumns"
      @submit="handleSubmitSearchVideo"
    />
    <dialog-columns-form
      v-model="formData"
      width="400px"
      title="订阅"
      :visible.sync="subscriptionShowed"
      :columns="subscriptionColumns"
      @submit="handleSubmitSubscription"
    />
    <dialog-columns-form
      v-model="formData"
      width="400px"
      title="猜你喜欢"
      :visible.sync="guessLikeShowed"
      :columns="guessLikeColumns"
      @submit="handleSubmitGuessLike"
    />
    <dialog-columns-form
      v-model="formData"
      width="400px"
      title="改价"
      :visible.sync="priceChangeShowed"
      :columns="priceChangeColumns"
      @submit="handleSubmitPriceChange"
    />
    <el-dialog width="700px" :visible.sync="showBatchRemoveDialog" title="批量清除">

      <el-checkbox :indeterminate="isIndeterminate" v-model="checkAll" @change="handleCheckAllChange">全选</el-checkbox>
      <div style="margin: 15px 0;"></div>
      <el-checkbox-group style="line-height: 2" v-model="checkedRemoveOption" @change="handleCheckedCitiesChange">
        <el-checkbox v-for="op in removeOptions" :label="op.prop" :key="op.prop">{{ op.label }}</el-checkbox>
      </el-checkbox-group>

      <div slot="footer" class="dialog-footer">
        <el-button type="default" size="mini" @click="showBatchRemoveDialog=false">取消</el-button>
        <el-button type="primary" size="mini" @click="handleSubmitBatchRemove">确认</el-button>
      </div>
    </el-dialog>
  </el-card>
</template>

<script>

import ColumnType from '@/framework/constant/ColumnType'
import {newProductIdRegisterApi} from '@/feature/pdt/infra/api/newProductIdRegisterApi'
import CURDTable from '@/framework/components/table/CURDTable'
import DateType from "@/framework/constant/DateType";
import DialogColumnsForm from "@/framework/components/form/DialogColumnsForm";
import {adminApi} from "@/feature/mgr/infra/api/adminApi";
import YesNoEnum from "@/infra/constant/YesNoEnum";
import DateUtil from "@/framework/infra/util/DateUtil";
import {storeApi} from "@/feature/mct/infra/api/storeApi";

export default {
  components: {DialogColumnsForm, CURDTable},

  data() {
    return {
      totalSaleNumShowed: false,
      dailyActShowed: false,
      blackBoxShowed: false,
      guideMaterialShowed: false,
      milkyWayShowed: false,
      microDetailShowed: false,
      combinationPurchaseShowed: false,
      searchVideoShowed: false,
      subscriptionShowed: false,
      guessLikeShowed: false,
      priceChangeShowed: false,
      blackBoxHelpShowed: false,
      cubeSuperRecommendedShowed: false,
      newGiftShowed: false,
      formData: {
        priceChangeDate: '',
        milkyWayDate: '',
        subscriptionDate: '',
        totalSalesNum: '',
        guessLikeDate: '',
        searchVideoDate: '',
        combinationPurchaseDate: '',
        microDetailDate: '',
        guideMaterialDate: '',
        blackBoxDate: '',
        dailyActDate: ''
      },
      checkAll: false,
      checkedRemoveOption: [],
      isIndeterminate: false,
      removeOptions: [
        {
          label: '日常活动日期',
          prop: 'dailyActDate'
        },
        {
          label: '小黑盒日期',
          span: 24,
          prop: 'blackBoxDate',
          required: true,
          type: ColumnType.DATE
        },
        {
          label: '导购素材日期',
          span: 24,
          prop: 'guideMaterialDate',
          required: true,
          type: ColumnType.DATE
        },
        {
          label: '银河日期',
          span: 24,
          prop: 'milkyWayDate',
          required: true,
          type: ColumnType.DATE
        },
        {
          label: '微详情日期',
          span: 24,
          prop: 'microDetailDate',
          required: true,
          type: ColumnType.DATE
        },
        {
          label: '搭配购日期',
          span: 24,
          prop: 'combinationPurchaseDate',
          required: true,
          type: ColumnType.DATE
        },
        {
          label: '搜索视频日期',
          span: 24,
          prop: 'searchVideoDate',
          required: true,
          type: ColumnType.DATE
        },
        {
          label: '订阅日期',
          span: 24,
          prop: 'subscriptionDate',
          required: true,
          type: ColumnType.DATE
        },
        {
          label: '猜你喜欢日期',
          span: 24,
          prop: 'guessLikeDate',
          required: true,
          type: ColumnType.DATE
        },
        {
          label: '改价日期',
          span: 24,
          prop: 'priceChangeDate',
          required: true,
          type: ColumnType.DATE
        }
      ],
      totalSaleNumColumns: [
        {
          label: '总销量',
          span: 24,
          prop: 'totalSalesNum',
          required: true,
          type: ColumnType.NUMBER
        }
      ],
      dailyActColumns: [
        {
          label: '日常活动日期',
          span: 24,
          prop: 'dailyActDate',
          required: true,
          type: ColumnType.DATE
        }
      ],
      blackBoxColumns: [
        {
          label: '小黑盒日期',
          span: 24,
          prop: 'blackBoxDate',
          required: true,
          type: ColumnType.DATE
        }
      ],
      guideMaterialColumns: [
        {
          label: '导购素材日期',
          span: 24,
          prop: 'guideMaterialDate',
          required: true,
          type: ColumnType.DATE
        }
      ],
      milkyWayColumns: [
        {
          label: '银河日期',
          span: 24,
          prop: 'milkyWayDate',
          required: true,
          type: ColumnType.DATE
        }
      ],
      microDetailColumns: [
        // {
        //   label: '微详情编码1',
        //   span: 24,
        //   prop: 'microDetailCode',
        //   required: true,
        //   type: ColumnType.TEXT
        // }, {
        //   label: '微详情编码2',
        //   span: 24,
        //   prop: 'microDetailCode2',
        //   required: false,
        //   type: ColumnType.TEXT
        // }, {
        //   label: '微详情编码3',
        //   span: 24,
        //   prop: 'microDetailCode3',
        //   required: false,
        //   type: ColumnType.TEXT
        // },
        {
          label: '微详情日期',
          span: 24,
          prop: 'microDetailDate',
          required: true,
          type: ColumnType.DATE
        }
      ],
      combinationPurchaseColumns: [
        {
          label: '搭配购日期',
          span: 24,
          prop: 'combinationPurchaseDate',
          required: true,
          type: ColumnType.DATE
        }
      ],
      searchVideoColumns: [
        {
          label: '搜索视频日期',
          span: 24,
          prop: 'searchVideoDate',
          required: true,
          type: ColumnType.DATE
        }
      ],
      subscriptionColumns: [
        {
          label: '订阅日期',
          span: 24,
          prop: 'subscriptionDate',
          required: true,
          type: ColumnType.DATE
        }
      ],
      guessLikeColumns: [
        {
          label: '猜你喜欢日期',
          span: 24,
          prop: 'guessLikeDate',
          required: true,
          type: ColumnType.DATE
        }
      ],
      priceChangeColumns: [
        {
          label: '改价日期',
          span: 24,
          prop: 'priceChangeDate',
          required: true,
          type: ColumnType.DATE
        }
      ],
      showBatchRemoveDialog: false,
      option: {
        opWidth: 400,
        requestApi: newProductIdRegisterApi,
        showSelection: true,
        columns: [
          {
            label: '店铺',
            prop: 'storeId',
            searchable: true,
            width: 120,
            type: ColumnType.SELECT,
            required: true,
            options: storeApi.options()
          }, {
            label: '编码',
            width: 180,
            searchable: true,
            prop: 'productCode'
          }, {
            label: 'ID',
            searchable: true,
            width: 120,
            searchOption: {
              options: {
                type: ColumnType.TEXTAREA
              }
            },
            prop: 'productNo'
          }, {
            label: '上新日期',
            width: 100,
            searchable: true,
            type: ColumnType.DATE,
            searchOption: {
              options: {
                type: DateType.DATERANGE
              }
            },
            prop: 'newDate'
          },
          // {
          //   label: '已填销量',
          //   width: 120,
          //   prop: 'totalSalesNumFlag',
          //   searchable: true,
          //   hiddenInTable: true,
          //   type: ColumnType.SELECT,
          //   options: YesNoEnum
          // },
          // {
          //   label: '总销量',
          //   width: 120,
          //   prop: 'totalSalesNum',
          //   type: ColumnType.NUMBER
          // }, {
          //   label: '总销量修改人',
          //   searchable: true,
          //   options: adminApi.listAll(),
          //   width: 120,
          //   prop: 'totalSalesNumManId',
          //   type: ColumnType.DATE
          // }, {
          //   label: '总销量修改日期',
          //   width: 120,
          //   prop: 'totalSalesNumDate',
          //   type: ColumnType.DATE
          // },
          {
            label: '已填日常活动',
            width: 120,
            prop: 'dailyActFlag',
            searchable: true,
            hiddenInTable: true,
            type: ColumnType.SELECT,
            options: YesNoEnum
          },
          {
            label: '日常活动日期',
            width: 120,
            searchable: true,
            type: ColumnType.DATE,
            searchOption: {
              options: {
                type: DateType.DATERANGE
              }
            },
            prop: 'dailyActDate'
          },
          {
            label: '日常活动负责人',
            width: 120,
            prop: 'dailyActManId',
            searchable: true,
            type: ColumnType.SELECT,
            options: adminApi.listAll()
          },
          {
            label: '已填小黑盒',
            width: 120,
            prop: 'blackBoxFlag',
            searchable: true,
            hiddenInTable: true,
            type: ColumnType.SELECT,
            options: YesNoEnum
          },
          {
            label: '小黑盒日期',
            width: 100,
            type: ColumnType.DATE,
            searchable: true,
            searchOption: {
              options: {
                type: DateType.DATERANGE
              }
            },
            prop: 'blackBoxDate'
          },
          {
            label: '小黑盒负责人',
            prop: 'blackBoxManId',
            searchable: true,
            width: 100,
            options: adminApi.listAll(),
            type: ColumnType.SELECT
          },
          {
            label: '已填导购素材',
            width: 120,
            prop: 'guideMaterialFlag',
            searchable: true,
            hiddenInTable: true,
            type: ColumnType.SELECT,
            options: YesNoEnum
          },
          {
            label: '导购素材日期',
            width: 100,
            searchable: true,
            type: ColumnType.DATE,
            searchOption: {
              options: {
                type: DateType.DATERANGE
              }
            },
            prop: 'guideMaterialDate'
          },
          {
            label: '导购素材负责人',
            width: 120,
            searchable: true,
            options: adminApi.listAll(),
            prop: 'guideMaterialManId',
            type: ColumnType.SELECT
          },
          {
            label: '已填银河',
            width: 120,
            prop: 'milkyWayFlag',
            searchable: true,
            hiddenInTable: true,
            type: ColumnType.SELECT,
            options: YesNoEnum
          },
          {
            width: 100,
            label: '银河日期',
            type: ColumnType.DATE,
            searchable: true,
            searchOption: {
              options: {
                type: DateType.DATERANGE
              }
            },
            prop: 'milkyWayDate'
          },
          {
            label: '银河负责人',
            prop: 'milkyWayManId',
            width: 100,
            searchable: true,
            options: adminApi.listAll(),
            type: ColumnType.SELECT
          },
          {
            label: '已填微详情',
            width: 120,
            prop: 'microDetailFlag',
            searchable: true,
            hiddenInTable: true,
            type: ColumnType.SELECT,
            options: YesNoEnum
          },
          // {
          //   label: '微详情编码1',
          //   width: 100,
          //   searchable: true,
          //   prop: 'microDetailCode'
          // }, {
          //   label: '微详情编码2',
          //   width: 100,
          //   searchable: true,
          //   prop: 'microDetailCode2'
          // }, {
          //   label: '微详情编码3',
          //   width: 100,
          //   searchable: true,
          //   prop: 'microDetailCode3'
          // },
          {
            label: '微详情日期',
            width: 100,
            searchable: true,
            type: ColumnType.DATE,
            searchOption: {
              options: {
                type: DateType.DATERANGE
              }
            },
            prop: 'microDetailDate'
          },
          {
            label: '微详情负责人',
            prop: 'microDetailManId',
            width: 100,
            searchable: true,
            options: adminApi.listAll(),
            type: ColumnType.SELECT
          },
          {
            label: '已填搭配购',
            width: 120,
            prop: 'combinationPurchaseFlag',
            searchable: true,
            hiddenInTable: true,
            type: ColumnType.SELECT,
            options: YesNoEnum
          },
          {
            label: '搭配购日期',
            width: 100,
            searchable: true,
            type: ColumnType.DATE,
            searchOption: {
              options: {
                type: DateType.DATERANGE
              }
            },
            prop: 'combinationPurchaseDate'
          },
          {
            label: '搭配购负责人',
            prop: 'combinationPurchaseManId',
            width: 100,
            searchable: true,
            options: adminApi.listAll(),
            type: ColumnType.SELECT
          },
          {
            label: '已填搜索视频',
            width: 120,
            prop: 'searchVideoFlag',
            searchable: true,
            hiddenInTable: true,
            type: ColumnType.SELECT,
            options: YesNoEnum
          },
          {
            label: '搜索视频日期',
            width: 100,
            searchable: true,
            type: ColumnType.DATE,
            searchOption: {
              options: {
                type: DateType.DATERANGE
              }
            },
            prop: 'searchVideoDate'
          },
          {
            label: '搜索视频负责人',
            width: 120,
            searchable: true,
            options: adminApi.listAll(),
            prop: 'searchVideoManId',
            type: ColumnType.SELECT
          },
          {
            label: '已填订阅',
            width: 120,
            prop: 'subscriptionFlag',
            searchable: true,
            hiddenInTable: true,
            type: ColumnType.SELECT,
            options: YesNoEnum
          },
          {
            width: 100,
            type: ColumnType.DATE,
            searchOption: {
              options: {
                type: DateType.DATERANGE
              }
            },
            searchable: true,
            label: '订阅日期',
            prop: 'subscriptionDate'
          },
          {
            label: '订阅负责人',
            width: 100,
            searchable: true,
            prop: 'subscriptionManId',
            options: adminApi.listAll(),
            type: ColumnType.SELECT
          },
          {
            label: '已填猜你喜欢',
            width: 120,
            prop: 'guessLikeFlag',
            searchable: true,
            hiddenInTable: true,
            type: ColumnType.SELECT,
            options: YesNoEnum
          },
          {
            width: 100,
            label: '猜你喜欢日期',
            searchable: true,
            type: ColumnType.DATE,
            searchOption: {
              options: {
                type: DateType.DATERANGE
              }
            },
            prop: 'guessLikeDate'
          },
          {
            label: '猜你喜欢负责人',
            width: 120,
            searchable: true,
            prop: 'guessLikeManId',
            options: adminApi.listAll(),
            type: ColumnType.SELECT
          },
          {
            label: '已填改价',
            width: 120,
            prop: 'priceChangeFlag',
            searchable: true,
            hiddenInTable: true,
            type: ColumnType.SELECT,
            options: YesNoEnum
          },
          {
            label: '改价日期',
            width: 100,
            searchable: true,
            type: ColumnType.DATE,
            searchOption: {
              options: {
                type: DateType.DATERANGE
              }
            },
            prop: 'priceChangeDate'
          },
          {
            label: '改价负责人',
            searchable: true,
            width: 100,
            options: adminApi.listAll(),
            prop: 'priceChangeManId',
            type: ColumnType.SELECT
          }
          // {
          //   width: 120,
          //   label: '小黑盒护航日期',
          //   searchable: true,
          //   type: ColumnType.DATE,
          //   searchOption: {
          //     options: {
          //       type: DateType.DATERANGE
          //     }
          //   },
          //   prop: 'blackBoxHelpDate'
          // },
          // {
          //   width: 120,
          //   label: '小黑盒护航负责人',
          //   searchable: true,
          //   prop: 'blackBoxHelpManId',
          //   options: adminApi.listAll(),
          //   type: ColumnType.SELECT
          // },
          // {
          //   label: '引力魔方+超级推荐日期',
          //   width: 180,
          //   searchable: true,
          //   type: ColumnType.DATE,
          //   searchOption: {
          //     options: {
          //       type: DateType.DATERANGE
          //     }
          //   },
          //   prop: 'cubeSuperRecommendedDate'
          // },
          // {
          //   label: '引力魔方+超级推荐负责人',
          //   width: 180,
          //   searchable: true,
          //   prop: 'cubeSuperRecommendedManId',
          //   options: adminApi.listAll(),
          //   type: ColumnType.SELECT
          // },
          // {
          //   label: '上新礼日期',
          //   searchable: true,
          //   type: ColumnType.DATE,
          //   searchOption: {
          //     options: {
          //       type: DateType.DATERANGE
          //     }
          //   },
          //   prop: 'newGiftDate'
          // },
          // {
          //   label: '上新礼负责人',
          //   prop: 'newGiftManId',
          //   searchable: true,
          //   options: adminApi.listAll(),
          //   type: ColumnType.SELECT
          // }
          // {
          //   label: '创建时间',
          //   type: ColumnType.DATETIME,
          //   hiddenInForm: true,
          //   prop: 'gmtCreate'
          // },
          // {
          //   label: '修改时间',
          //   type: ColumnType.DATETIME,
          //   hiddenInForm: true,
          //   prop: 'gmtModified'
          // }
        ]
      }
    }
  },
  methods: {
    handleCheckAllChange(val) {
      this.checkedRemoveOption = val ? this.removeOptions.map(el => el.prop) : []
      this.isIndeterminate = false
    },
    handleCheckedCitiesChange(value) {
      let checkedCount = value.length
      this.checkAll = checkedCount === this.removeOptions.length
      this.isIndeterminate = checkedCount > 0 && checkedCount < this.removeOptions.length;
    },
    async handleRemove({arg, $service}) {
      await this.$confirm('确认清除吗？', '提示')
      await newProductIdRegisterApi.remove(arg.productRegisterExtraId)
      this.$message.success('清除成功')
      $service.reloadTable()
    },
    async handleBatchRemove({arg, $service}) {
      if (!$service.hasSelectOne) {
        this.$message.error('请选择至少一条记录')
        return
      }
      this.selectedItems = $service.selectedItems
      this.showBatchRemoveDialog = true
    },
    async handleSubmitBatchRemove() {
      if (!this.checkedRemoveOption.length) {
        this.$message.error('请选择需要清除的选项')
        return
      }
      const productRegisterExtraIdList = this.selectedItems.map(el => el.productRegisterExtraId).filter(el => el)
      if (!productRegisterExtraIdList.length) {
        this.$message.error('请选择可以清除的记录')
        return
      }
      // await this.$confirm('确认清除所选记录吗？', '提示')
      await newProductIdRegisterApi.removeMany(productRegisterExtraIdList, this.checkedRemoveOption)
      this.$message.success('清除成功')
      this.$refs.table.reloadTable()
      this.showBatchRemoveDialog = false
    },

    handleTotalSaleNum({arg}) {
      this.formData = {...arg}
      this.totalSaleNumShowed = true
    },
    handleBatchDailyAct({$service}) {
      if (!$service.hasSelectOne) {
        $service.error('请选择至少一条记录')
        return
      }
      // 是批量操作
      this.batchSelectedIds = $service.selectedIds
      this.formData.dailyActDate = DateUtil.currentDate()
      this.dailyActShowed = true
    },
    handleDailyAct({arg}) {
      this.formData = {...arg}
      this.batchSelectedIds = null
      this.formData.dailyActDate = this.formData.dailyActDate || DateUtil.currentDate()
      this.dailyActShowed = true
    },
    handleBlackBox({arg}) {
      this.formData = {...arg}
      this.batchSelectedIds = null
      this.formData.blackBoxDate = this.formData.blackBoxDate || DateUtil.currentDate()
      this.blackBoxShowed = true
    },
    handleBatchBlackBox({$service}) {
      if (!$service.hasSelectOne) {
        $service.error('请选择至少一条记录')
        return
      }
      // 是批量操作
      this.batchSelectedIds = $service.selectedIds
      this.formData.blackBoxDate = DateUtil.currentDate()
      this.blackBoxShowed = true
    },
    handleGuideMaterial({arg}) {
      this.formData = {...arg}
      this.batchSelectedIds = null
      this.formData.guideMaterialDate = this.formData.guideMaterialDate || DateUtil.currentDate()
      this.guideMaterialShowed = true
    },
    handleBatchGuideMaterial({$service}) {
      if (!$service.hasSelectOne) {
        $service.error('请选择至少一条记录')
        return
      }
      // 是批量操作
      this.batchSelectedIds = $service.selectedIds
      this.formData.guideMaterialDate = DateUtil.currentDate()
      this.guideMaterialShowed = true
    },
    handleMilkyWay({arg}) {
      this.formData = {...arg}
      this.batchSelectedIds = null
      this.formData.milkyWayDate = this.formData.milkyWayDate || DateUtil.currentDate()
      this.milkyWayShowed = true
    },
    handleBatchMilkyWay({$service}) {
      if (!$service.hasSelectOne) {
        $service.error('请选择至少一条记录')
        return
      }
      this.batchSelectedIds = $service.selectedIds
      this.formData.milkyWayDate = DateUtil.currentDate()
      this.milkyWayShowed = true
    },
    handleMicroDetail({arg}) {
      this.formData = {...arg}
      this.batchSelectedIds = null
      this.formData.microDetailDate = this.formData.microDetailDate || DateUtil.currentDate()
      this.microDetailShowed = true
    },
    handleBatchMicroDetail({$service}) {
      if (!$service.hasSelectOne) {
        $service.error('请选择至少一条记录')
        return
      }
      this.batchSelectedIds = $service.selectedIds
      this.formData.microDetailDate = DateUtil.currentDate()
      this.microDetailShowed = true
    },
    handleCombinationPurchase({arg}) {
      this.formData = {...arg}
      this.batchSelectedIds = null
      this.formData.combinationPurchaseDate = this.formData.combinationPurchaseDate || DateUtil.currentDate()
      this.combinationPurchaseShowed = true
    },
    handleBatchCombinationPurchase({$service}) {
      if (!$service.hasSelectOne) {
        $service.error('请选择至少一条记录')
        return
      }
      this.batchSelectedIds = $service.selectedIds
      this.formData.combinationPurchaseDate = DateUtil.currentDate()
      this.combinationPurchaseShowed = true
    },
    handleSearchVideo({arg}) {
      this.formData = {...arg}
      this.batchSelectedIds = null
      this.formData.searchVideoDate = this.formData.searchVideoDate || DateUtil.currentDate()
      this.searchVideoShowed = true
    },
    handleBatchSearchVideo({$service}) {
      if (!$service.hasSelectOne) {
        $service.error('请选择至少一条记录')
        return
      }
      this.batchSelectedIds = $service.selectedIds
      this.formData.searchVideoDate = DateUtil.currentDate()
      this.searchVideoShowed = true
    },
    handleSubscription({arg}) {
      this.formData = {...arg}
      this.batchSelectedIds = null
      this.formData.subscriptionDate = this.formData.subscriptionDate || DateUtil.currentDate()
      this.subscriptionShowed = true
    },
    handleBatchSubscription({$service}) {
      if (!$service.hasSelectOne) {
        $service.error('请选择至少一条记录')
        return
      }
      this.batchSelectedIds = $service.selectedIds
      this.formData.subscriptionDate = DateUtil.currentDate()
      this.subscriptionShowed = true
    },
    handleGuessLike({arg}) {
      this.formData = {...arg}
      this.batchSelectedIds = null
      this.formData.guessLikeDate = this.formData.guessLikeDate || DateUtil.currentDate()
      this.guessLikeShowed = true
    },
    handleBatchGuessLike({$service}) {
      if (!$service.hasSelectOne) {
        $service.error('请选择至少一条记录')
        return
      }
      this.batchSelectedIds = $service.selectedIds
      this.formData.guessLikeDate = DateUtil.currentDate()
      this.guessLikeShowed = true
    },
    handlePriceChange({arg}) {
      this.formData = {...arg}
      this.batchSelectedIds = null
      this.formData.priceChangeDate = this.formData.priceChangeDate || DateUtil.currentDate()
      this.priceChangeShowed = true
    },
    handleBatchPriceChange({$service}) {
      if (!$service.hasSelectOne) {
        $service.error('请选择至少一条记录')
        return
      }
      this.batchSelectedIds = $service.selectedIds
      this.formData.priceChangeDate = DateUtil.currentDate()
      this.priceChangeShowed = true
    },
    handleSubmitTotalSaleNum({done}) {
      newProductIdRegisterApi.updateTotalSaleNum({
        idList: this.formData.id,
        totalSalesNum: this.formData.totalSalesNum
      }).then(() => {
        this.totalSaleNumShowed = false
        this.$refs.table.reloadTable()
        this.$success('更新成功')
      }).finally(() => {
        done()
      })
    },
    handleSubmitDailyAct({done}) {
      newProductIdRegisterApi.updateDailyAct({
        idList: this.batchSelectedIds && this.batchSelectedIds.length ? this.batchSelectedIds : [this.formData.id],
        dailyActDate: this.formData.dailyActDate
      }).then(() => {
        this.dailyActShowed = false
        this.$refs.table.reloadTable()
        this.$success('更新成功')
      }).finally(() => {
        done()
      })
    },
    handleSubmitPriceChange({done}) {
      newProductIdRegisterApi.updatePriceChange({
        idList: this.batchSelectedIds && this.batchSelectedIds.length ? this.batchSelectedIds : [this.formData.id],
        priceChangeDate: this.formData.priceChangeDate
      }).then(() => {
        this.priceChangeShowed = false
        this.$refs.table.reloadTable()
        this.$success('更新成功')
      }).finally(() => {
        done()
      })
    },
    handleSubmitGuessLike({done}) {
      newProductIdRegisterApi.updateGuessLike({
        idList: this.batchSelectedIds && this.batchSelectedIds.length ? this.batchSelectedIds : [this.formData.id],
        guessLikeDate: this.formData.guessLikeDate
      }).then(() => {
        this.guessLikeShowed = false
        this.$refs.table.reloadTable()
        this.$success('更新成功')
      }).finally(() => {
        done()
      })
    },
    handleSubmitSubscription({done}) {
      newProductIdRegisterApi.updateSubscription({
        idList: this.batchSelectedIds && this.batchSelectedIds.length ? this.batchSelectedIds : [this.formData.id],
        subscriptionDate: this.formData.subscriptionDate
      }).then(() => {
        this.subscriptionShowed = false
        this.$refs.table.reloadTable()
        this.$success('更新成功')
      }).finally(() => {
        done()
      })
    },
    handleSubmitCombinationPurchase({done}) {
      newProductIdRegisterApi.updateCombinationPurchase({
        idList: this.batchSelectedIds && this.batchSelectedIds.length ? this.batchSelectedIds : [this.formData.id],
        combinationPurchaseDate: this.formData.combinationPurchaseDate
      }).then(() => {
        this.combinationPurchaseShowed = false
        this.$refs.table.reloadTable()
        this.$success('更新成功')
      }).finally(() => {
        done()
      })
    },
    handleSubmitMicroDetail({done}) {
      newProductIdRegisterApi.updateMicroDetail({
        idList: this.batchSelectedIds && this.batchSelectedIds.length ? this.batchSelectedIds : [this.formData.id],
        microDetailCode: this.formData.microDetailCode,
        microDetailCode2: this.formData.microDetailCode2,
        microDetailCode3: this.formData.microDetailCode3,
        microDetailDate: this.formData.microDetailDate
      }).then(() => {
        this.microDetailShowed = false
        this.$refs.table.reloadTable()
        this.$success('更新成功')
      }).finally(() => {
        done()
      })
    },
    handleSubmitMilkyWay({done}) {
      newProductIdRegisterApi.updateMilkyWay({
        idList: this.batchSelectedIds && this.batchSelectedIds.length ? this.batchSelectedIds : [this.formData.id],
        milkyWayDate: this.formData.milkyWayDate
      }).then(() => {
        this.milkyWayShowed = false
        this.$refs.table.reloadTable()
        this.$success('更新成功')
      }).finally(() => {
        done()
      })
    },
    handleSubmitGuideMaterial({done}) {
      newProductIdRegisterApi.updateGuideMaterial({
        idList: this.batchSelectedIds && this.batchSelectedIds.length ? this.batchSelectedIds : [this.formData.id],
        guideMaterialDate: this.formData.guideMaterialDate
      }).then(() => {
        this.guideMaterialShowed = false
        this.$refs.table.reloadTable()
        this.$success('更新成功')
      }).finally(() => {
        done()
      })
    },
    handleSubmitSearchVideo({done}) {
      newProductIdRegisterApi.updateSearchVideo({
        idList: this.batchSelectedIds && this.batchSelectedIds.length ? this.batchSelectedIds : [this.formData.id],
        searchVideoDate: this.formData.searchVideoDate
      }).then(() => {
        this.searchVideoShowed = false
        this.$refs.table.reloadTable()
        this.$success('更新成功')
      }).finally(() => {
        done()
      })
    },
    handleSubmitBlackBox({done}) {
      newProductIdRegisterApi.updateBlackBox({
        idList: this.batchSelectedIds && this.batchSelectedIds.length ? this.batchSelectedIds : [this.formData.id],
        blackBoxDate: this.formData.blackBoxDate
      }).then(() => {
        this.blackBoxShowed = false
        this.$refs.table.reloadTable()
        this.$success('更新成功')
      }).finally(() => {
        done()
      })
    }
  }
}
</script>

